<template>
  <div class="container">
  <!-- 导航栏  -->
    <nav-bar>
      <template #center>
        <h4>购物车({{length}})</h4>
      </template>
    </nav-bar>

    <!-- 滚动组件  -->
    <scroll :probe-type=1 class="wrapper">
      <div class="noProduct" v-if="length === 0">
        您没有添加任何商品
      </div>

      <!-- 列表  -->
      <cart-list v-else/>

    </scroll>

    <cart-bottom-bar class="cartBottonBar"/>
  </div>
</template>

<script>
  import NavBar from "components/common/navbar/NavBar";
  import Scroll from "components/common/scroll/Scroll";
  import CartList from "./childComps/CartList";
  import CartBottomBar from "./childComps/CartBottomBar";
  import { mapGetters } from 'vuex'

  export default {
    name: "Cart",
    components: {
      NavBar,
      Scroll,
      CartList,
      CartBottomBar
    },
    computed: {
      // ...mapGetters(['cartListLength'])
      ...mapGetters({
        length: 'cartListLength'
      })
    },
  }
</script>

<style scoped>
  .container{
    position: relative;
    height: calc(100vh - 50px);
  }
  .wrapper{
    position: absolute;
    top: 44px;
    left: 0;
    right: 0;
    bottom: 40px;
  }
  .noProduct{
    text-align: center;
    line-height: 100px;
  }
  .cartBottonBar{
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
  }
</style>
